package com.spsy.pay.config;

import com.spsy.pay.constant.RabbitMqConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: Kyrie Irving
 * @Date: 2025/9/23 16:49
 * @Description:
 **/
//@Configuration
public class RabbitmqConfig {
    @Bean                               //两个参数（队列名称，是否持久化）
    public Queue createQueue(){
        return new Queue(RabbitMqConstant.MQ_NAME,true);
    }

    @Bean
    public DirectExchange createExChange(){
        return new DirectExchange(RabbitMqConstant.MQ_EXCHANGE);
    }

    @Bean
    public Binding createBinding(){
        return BindingBuilder.bind(this.createQueue()).to(this.createExChange()).with(RabbitMqConstant.MQ_ROUTING);
    }
}
